<script>
  /*
  * Copyright (c) 2012-2013 RockStor, Inc. <http://rockstor.com>
  * This file is part of RockStor.
  *
  * RockStor is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published
  * by the Free Software Foundation; either version 2 of the License,
  * or (at your option) any later version.
  *
  * RockStor is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  *
  */
</script>
<div class="row">
  <div class="col-md-8">
    <div class="panel panel-default">
      {{#unless username}}
      <div class="panel-heading">Create a new user</div>
      {{else}}
      <div class="panel-heading">Edit User</div>
      {{/unless}}

    <div class="panel-body">
      <form class="form-horizontal" id="user-create-form" name="aform" class="form-horizontal">

        <div class="messages"></div>
        <div class="form-group">
	  {{#if username}}
          <label class="col-sm-4 control-label" for="username">Username (UID)</label>
	  {{else}}
	  <label class="col-sm-4 control-label" for="username">Username<span class="required"> *</span></label>
	  {{/if}}

	  {{#if username}}
	  <div class="col-sm-4"> <!-- Inline styling since this is the first instance of this case -->
	    <input type="text" class="form-control" disabled value="{{username}} ({{user.uid}})" />
	  </div>
	  <div class="col-sm-offset-4 col-sm-8">
            <input class="form-control" type="hidden" id="username" name="username" value="{{username}}">
	  </div>
	  {{else}}
	  <div class="col-sm-4">
            <input class="form-control" type="text" id="username" name="username" placeholder="Username" title="Username must start with a letter and can contain letters, numbers, - and _ characters. It cannot exceed 30 characters in length.">
	  </div>
	  {{/if}}
        </div>
        <div class="form-group">
	  <div class="col-sm-offset-4 col-sm-8">
            <div class="checkbox">
              <label>
		{{#if user.user}}
                <input class="checkbox-inline" type="checkbox" id="admin" name="admin" placeholder="Admin" checked="true">
		{{else}}
                <input class="checkbox-inline" type="checkbox" id="admin" name="admin" placeholder="Admin">
		{{/if}}
		Allow this user to login to RockStor Web UI?
              </label>
            </div>
	  </div>
        </div>
        <div class="form-group">
	  {{#unless username}}
          <label class="col-sm-4 control-label">Password<span class="required"> *</span></label>
	  {{else}}
	  <label class="col-sm-4 control-label">Password<span class="required"></span></label>
	  {{/unless}}
	  <div class="col-sm-4">
	    <input class="form-control" type="password" id="password" name="password" placeholder="Password">
	  </div>
        </div>
        <div class="form-group">
	  {{#unless username}}
          <label class="col-sm-4 control-label">Confirm Password<span class="required"> *</span></label>
	  {{else}}
	  <label class="col-sm-4 control-label">Confirm Password<span class="required"></span></label>
	  {{/unless}}

	  <div class="col-sm-4">
            <input class="form-control" type="password" id="password_confirmation" name="password_confirmation" placeholder="Password">
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-4 control-label">Public key</label>
          <div class="col-sm-8">
	    {{#if user.public_key}}
            <textarea class="form-control" rows="2" cols="50" id="public_key" name="public_key"> {{user.public_key}} </textarea>
	    {{else}}
            <textarea class="form-control" rows="2" cols="50" id="public_key" name="public_key" />
	    {{/if}}
          </div>
        </div>
	<div class="form-group">
	  <label class="col-sm-4 control-label" for="shell">Login shell<span class="required"></span></label>
	  <div class="col-sm-4">
	    <select class="form-control" id="shell" name="shell">
	      {{#each shells}}
              <option value="{{this}}">{{this}} </option>
	      {{/each}}
	    </select>
	  </div>
	</div>
	{{#unless username}}
	<div class="form-group">
	  <label class="col-sm-4 control-label">UID</label>
	  <div class="col-sm-4">
	    <input class="form-control" type="text" id="uid" name="uid" placeholder="Create a new one" title="Enter a custom uid here or one will be autogenerated">
	  </div>
	</div>
	<div class="form-group">
	  <label class="col-sm-4 control-label">Group</label>
	  <div class="col-sm-4">
	    <select class="form-conrol" name="group" id="group" title="Select a primary group from the list of one will be autogenerated" data-placeholder="Autogenerate">
	      <option value="Autogenerate" selected="selected">Create a new one</option>
	      {{#each groups}}
              <option value="{{this.groupname}}">{{this.groupname}}</option>
	      {{/each}}
	    </select>
	  </div>
	</div>
	{{/unless}}
	<div class="form-group">
	  <label class="col-sm-4 control-label">Email</label>
	  <div class="col-sm-4">
	    {{#unless username}}
	    <input class="form-control" type="text" id="email" name="email" title="Enter an email address to associate with the user">
	    {{else}}
	    <input class="form-control" type="text" id="email" name="email" title="Enter an email address to associate with the user" value="{{user.email}}">
	    {{/unless}}
	  </div>
	</div>
	<div class="form-group">
	  <div class="col-sm-offset-4 col-sm-8">
	    <button id="cancel" class="btn btn-default">Cancel</button>
	    <button type="Submit" id="create-user" class="btn btn-primary">Submit</button>
	  </div>
	</div>
      </form>
    </div>
  </div>
</div>
